/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package connection;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import model.Genre;

/**
 *
 * @author Student
 */
public class DaoGenre {

    public ArrayList<Genre> getGenre() throws SQLException {
        ArrayList<Genre> list = new ArrayList<Genre>();
        Genre genre = null;

        Connector connect = new Connector();
        Connection conn = connect.getConn();

        String query = "select "
                + " genre_id, "
                + " genre "
                + " from ROOT.Genre "
                + " order by genre ";

        PreparedStatement ps = conn.prepareStatement(query);

        ResultSet rs = ps.executeQuery();
//if was able to get a row
        while (rs.next()) {
            genre = new Genre(rs.getInt("GENRE_ID"),
                    rs.getString("GENRE"));

            list.add(genre);

          
        }


        return list;

    }

    public ArrayList<Genre> retrieveGetGenre() throws SQLException {
        return this.getGenre();

    }
}
